<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center searchs_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center  flex-sub searchs_fd0_0'>
					<text class='fu-iconfont2  searchs_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">&#xE794;</text>
					<view class='flex flex-wrap align-center searchs_fd0_0_c1001' v-if="appSystemIdentification=='Wechat'">
						<benben-input class='flex-sub searchs_fd0_0_c1_c0' type="text" :focus='true'
							:placeholder="`${keyword}`" confirm-type="done" :maxlength="50"
							placeholder-style="color:#999;font-size:24rpx" @confirm="addSearchHistoryFuncFunc(onlys)"
							v-model="onlys" />
					</view>
					<view class='flex flex-wrap align-center searchs_fd0_0_c1' v-if=" appSystemIdentification!='Wechat'">
						<benben-input class='flex-sub searchs_fd0_0_c1_c0' type="text" :focus='true'
							:placeholder="`${keyword}`" confirm-type="done" :maxlength="50"
							placeholder-style="color:#999;font-size:24rpx" @confirm="addSearchHistoryFuncFunc(onlys)"
							v-model="onlys" />
					</view>
					<text class='fu-iconfont2  searchs_fd0_0_c2'
						@tap.stop="addSearchHistoryFuncFunc(onlys)">&#xE722;</text>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---搜索记录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout searchs_flex_1">
				<view class='flex flex-wrap align-center searchs_fd1_0'>
					<image class='searchs_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"188.png"'></image>
					<text class='searchs_fd1_0_c1'>历史搜索</text>
					<image class='searchs_fd1_0_c2' mode="aspectFit" :src='STATIC_URL+"189.png"'
						@tap.stop="popupShow1661481796822=true" v-if=" appSearchHistory.length!=''"></image>
				</view>
				<view class='flex flex-wrap align-center searchs_fd1_1' v-if=" appSearchHistory.length!=''">
					<template v-for='(item,key0) in appSearchHistory'>
						<view class='flex flex-wrap align-center searchs_fd1_1_c0' @tap.stop="handleJumpDiy"
							data-type="navigateTo"
							:data-url="`/pages/index/searchReasult/searchReasult?keyword=${item.name}`"
							@longpress="handleLongpressFunc(item.name)" :key='key0'>
							<text class='searchs_fd1_1_c0_c0'>{{item.name}}</text>
							<image class='searchs_fd1_1_c0_c1' mode="aspectFit" :src='STATIC_URL+"190.png"'
								@tap.stop="deleteSearchHistoryFunc(item.name)" v-if=" item.name==removeIndex"></image>
						</view>
					</template>

				</view>
				<text class='searchs_fd1_2' v-if=" appSearchHistory.length==''">暂无历史记录</text>
				<view class='flex flex-wrap align-center searchs_fd1_3'>
					<image class='searchs_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"191.png"'></image>
					<text class='searchs_fd1_3_c1'>搜索发现</text>
					<text class='searchs_fd1_3_c2' @tap="getFindFunc()">换一批</text>
				</view>
				<view class='flex flex-wrap align-center searchs_fd1_1'>
					<template v-for='(item,key0) in findList'>
						<view class='flex flex-wrap align-center searchs_fd1_4_c0'
							@tap.stop="addSearchHistoryFuncFunc(item.name)" :key='key0'>
							<button class='searchs_fd1_4_c0_c0' v-if=" key0==0">{{item.name}}</button><button
								class='searchs_fd1_4_c0_c0_1' v-if=" key0>'1'">{{item.name}}</button><button
								class='searchs_fd1_4_c0_c0' v-if=" key0=='1'">{{item.name}}</button>
							<image class='searchs_fd1_4_c0_c1' mode="aspectFit" :src='STATIC_URL+"354.png"'
								v-if=" key0==0 || key0=='1'"></image>
						</view>
					</template>

				</view>
			</view>

			<!---搜索记录flex布局结束-->
			<benben-popup v-model="popupShow1661481796822" :mask="true" :mask-close-able="false" mode='center'>
				<!---删除历史记录弹窗flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center searchs_flex_2">
					<text class='searchs_fd2_0'>确定删除历史记录？</text>
					<view class='flex flex-wrap align-center searchs_fd2_1'>
						<button class='searchs_fd2_1_c0' @tap.stop="popupShow1661481796822=false">取消</button>
						<button class='searchs_fd2_1_c1' @tap.stop="emptySearchHistoryFunc()">确定</button>
					</view>
				</view>

				<!---删除历史记录弹窗flex布局结束-->

			</benben-popup>

			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout searchs_flex_3">
				<view class='flex flex-wrap align-center searchs_fd3_0'>
					<image class='searchs_fd3_0_c0' mode="aspectFit" :src='STATIC_URL+"193.png"'></image>
					<text class='searchs_fd3_0_c1'>全网热搜榜</text>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch searchs_fd3_1'>
					<template v-for='(item,key0) in hotSearchList'>
						<view class='flex flex-wrap align-center searchs_fd3_1_c0' :key='key0'>
							<image class='searchs_fd3_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"194.png"'
								v-if=" key0==0"></image>
							<image class='searchs_fd3_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"197.png"'
								v-if=" key0=='1'"></image>
							<image class='searchs_fd3_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"199.png"'
								v-if=" key0=='2'"></image>
							<text class='searchs_fd3_1_c0_c1' v-if=" key0>'2'">{{key0+1}}</text>
							<text class='searchs_fd3_1_c0_c2'
								@tap="hotNavToFunc(item.service_title,item.aid)">{{item.service_title}}</text>
							<image class='searchs_fd3_1_c0_c3' mode="aspectFit" :src='STATIC_URL+"195.png"'
								v-if=" item.is_hot=='1'"></image>
							<image class='searchs_fd3_1_c0_c4' mode="aspectFit" :src='STATIC_URL+"198.png"'
								v-if=" item.is_new=='1'"></image>
						</view>
					</template>

					<view class='flex align-center justify-between'>
						<view class='flex flex-wrap align-center justify-center flex-sub searchs_fd3_1_c1_c0'
							@tap="handleJumpDiy" data-type="navigateTo"
							:data-url="`/pages/index/searchList/searchList`">
							<image class='searchs_fd3_1_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"200.png"'></image>
							<text class='searchs_fd3_1_c1_c0_c1'>查看榜单</text>
						</view>
					</view>
				</view>
			</view>




		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"popupShow1661481796822": false,
				"keyword": "",
				"findList": [],
				"hotSearchList": [],
				"removeIndex": "name",
				"onlys": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			appSearchHistory() { // 搜索历史
				return this.$store.state.appSearchHistory
			},
			/**
			 * @returns 
			 * Android       安卓
			 * IOS       苹果
			 * Web       H5 或 pc
			 * Wechat       微信小程序
			 * Alipay       支付宝小程序
			 * Baidu       百度小程序
			 * ByteBounce       抖音小程序
			 * 360       360小程序
			 * FastApp       快应用
			 */
			appSystemIdentification() {
				return this.$store.state.appSystemIdentification
			}
		},
		watch: {},
		onLoad(options) {
			let {
				keyword
			} = options
			if (keyword !== undefined) this.keyword = keyword
			this.getFindFunc()
			this.getHotSearchFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//删除搜索历史
			deleteSearchHistoryFunc(name) {
				this.$store.commit('appSearchHistoryDel', {
					"name": name
				})

			},
			//清空搜索记录
			emptySearchHistoryFunc() {
				this.$store.commit('appSearchHistoryClean')
				this.popupShow1661481796822 = false;
			},
			//获取搜索发现列表
			async getFindFunc() {
				//请求方法
				//数据验证

				let datafindList = await this.$api.get(global.apiUrls.post6413b4f0c19b3, {

				});

				if (datafindList.data.code != 1) {
					this.$message.info(datafindList.data.msg);
					return
				}
				let infofindList = datafindList.data;
				this.findList = infofindList.data

			},
			//获取热搜榜单列表
			async getHotSearchFunc() {
				//请求方法
				//数据验证

				let datahotSearchList = await this.$api.get(global.apiUrls.post6413b42868ec8, {

				});

				if (datahotSearchList.data.code != 1) {
					this.$message.info(datahotSearchList.data.msg);
					return
				}
				let infohotSearchList = datahotSearchList.data;
				this.hotSearchList = infohotSearchList.data

			},
			//长按事件
			handleLongpressFunc(index) {
				this.removeIndex = index;
			},
			//添加搜索历史
			addSearchHistoryFuncFunc(unique) {
				this.$store.commit('appSearchHistoryAdd', {
					"name": unique || this.keyword
				})
				let keys = unique || this.keyword
				this.$urouter.navigateTo(`/pages/index/searchReasult/searchReasult?keyword=${keys}`);
			},
			//全网热搜榜跳转
			hotNavToFunc(keyword, id) {
				this.$store.commit('appSearchHistoryAdd', {
					"name": keyword
				})
				this.$urouter.navigateTo(`/pages/index/serviceDetails/serviceDetails?id=${id}&serviceName=${keyword}`);
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto;
	}

	.searchs_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.searchs_fd0_0_c2 {
		width: 40rpx;
		height: 40rpx;
		font-size: 36rpx;
		font-weight: 500;
	}

	.searchs_fd0_0_c1_c0 {
		margin: 0rpx 24rpx 0rpx 24rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #333;
	}

	.searchs_fd0_0_c1 {
		background: rgba(249, 249, 249, 1);
		background-size: 100% auto !important;
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		width: 574rpx;
		height: 64rpx;
		margin: 0rpx 16rpx 0rpx 16rpx;
	}
	.searchs_fd0_0_c1001 {
		background: rgba(249, 249, 249, 1);
		background-size: 100% auto !important;
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		width: 370rpx;
		height: 64rpx;
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	.searchs_fd0_0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.searchs_fd0_0 {
		margin: 17rpx 32rpx 0rpx 32rpx;
	}

	.searchs_flex_1 {
		padding: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchs_fd1_4_c0_c1 {
		width: 18rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		position: absolute;
		top: -8rpx;
		right: 4rpx;
	}

	.searchs_fd1_4_c0_c0_1 {
		background: rgba(248, 248, 248, 1);
		border-radius: 33rpx 33rpx 33rpx 33rpx;
		font-size: 24rpx;
		color: rgba(51, 51, 51, 1);
		padding: 0rpx 40rpx 0rpx 40rpx;
		height: 56rpx;
		line-height: 56rpx;
	}

	.searchs_fd1_4_c0_c0 {
		border: 1px solid var(--benbenbdColor2);
		background: rgba(255, 255, 255, 1);
		border-radius: 33rpx 33rpx 33rpx 33rpx;
		font-size: 24rpx;
		color: rgba(11, 11, 11, 1);
		padding: 0rpx 40rpx 0rpx 40rpx;
		height: 56rpx;
		line-height: 56rpx;
	}

	.searchs_fd1_4_c0 {
		margin: 0rpx 12rpx 24rpx 12rpx;
		position: relative;
	}

	.searchs_fd1_3_c2 {
		border: 1px solid #BFBFBF;
		margin: 0rpx 0rpx 0rpx auto;
		padding: 8rpx 16rpx 8rpx 16rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
	}

	.searchs_fd1_3_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(51, 51, 51, 1);
	}

	.searchs_fd1_3 {
		padding: 32rpx 0rpx 15rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	.searchs_fd1_2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #666666;
		margin: 0rpx 0rpx 32rpx 24rpx;
	}

	.searchs_fd1_1_c0_c1 {
		width: 18rpx;
		height: 18rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
	}

	.searchs_fd1_1_c0_c0 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
	}

	.searchs_fd1_1_c0 {
		background: rgba(248, 248, 248, 1);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		background-size: 100% auto !important;
		padding: 0rpx 40rpx 0rpx 40rpx;
		line-height: 56rpx;
		margin: 0rpx 12rpx 24rpx 12rpx;
	}

	.searchs_fd1_1 {
		padding: 0rpx 0rpx 0rpx 12rpx;
	}

	.searchs_fd1_0_c2 {
		width: 24rpx;
		height: 28rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.searchs_fd1_0_c1 {
		font-size: 32rpx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}

	.searchs_fd1_0_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 17rpx 17rpx 17rpx 17rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.searchs_fd1_0 {
		padding: 32rpx 0rpx 24rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	.searchs_flex_2 {
		background: #fff;
		margin: 0rpx 105rpx 0rpx 105rpx;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
	}

	.searchs_fd2_1_c1 {
		background: transparent;
		line-height: 45rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor4);
		padding: 24rpx 103rpx 24rpx 99rpx;
	}

	.searchs_fd2_1_c0 {
		border-right: 1px solid #EEEEEE;
		background: transparent;
		line-height: 45rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		padding: 24rpx 103rpx 24rpx 103rpx;
	}

	.searchs_fd2_1 {
		border-top: 1px solid #eee;
	}

	.searchs_fd2_0 {
		font-size: 32rpx;
		font-weight: 400;
		line-height: 52rpx;
		color: #333333;
		margin: 56rpx 0rpx 64rpx 0rpx;
	}

	.searchs_flex_3 {
		padding: 0rpx 24rpx 24rpx 24rpx;
	}

	.searchs_fd3_1_c1_c0_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
	}

	.searchs_fd3_1_c1_c0_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 8rpx 0rpx 0rpx;
	}

	.searchs_fd3_1_c1_c0 {
		background: #F9F9F9;
		margin: 16rpx 0rpx 0rpx 0rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		line-height: 80rpx;
		width: 306rpx;
		height: 80rpx;
	}

	.searchs_fd3_1_c0_c4 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchs_fd3_1_c0_c3 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.searchs_fd3_1_c0_c2 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(34, 34, 34, 1);
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.searchs_fd3_1_c0_c1 {
		margin: 0rpx 24rpx 0rpx 0rpx;
		width: 38rpx;
		text-align: center;
		color: var(--benbenFontColor4);
	}

	.searchs_fd3_1_c0_c0 {
		width: 38rpx;
		height: 38rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.searchs_fd3_1_c0 {
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.searchs_fd3_1 {
		background: #fff;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		box-shadow: 0rpx 0rpx 16rpx rgba(0, 0, 0, 0.0800);
		background-size: 100% auto !important;
		padding: 32rpx 24rpx 56rpx 24rpx;
	}

	.searchs_fd3_0_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(51, 51, 51, 1);
	}

	.searchs_fd3_0_c0 {
		width: 34rpx;
		height: 34rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.searchs_fd3_0 {
		padding: 32rpx 0rpx 24rpx 0rpx;
	}
</style>